package com.chuangmei.com.arindoorlocationsystem.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.chuangmei.com.arindoorlocationsystem.base.StoreApplication;

/**
 * 项目名称：ARIndoorLocationSystem
 * 类描述：难分类的工具类
 * 创建人：Administrator
 * 创建时间：2018/4/4 17:24
 * 修改人：Administrator
 * 修改时间：2018/4/4 17:24
 * 修改备注：
 */

public class SharedPreferencesUtils {

    public static void setUserMessage(String field, boolean value) {
        Context context = StoreApplication.getContext();
        SharedPreferences sharedPreferences = context.getSharedPreferences("userMessage", Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putBoolean(field, value);
        edit.commit();
    }

    public static String getUserMessage(String field) {
        Context context = StoreApplication.getContext();
        SharedPreferences sharedPreferences = context.getSharedPreferences("userMessage", Context.MODE_PRIVATE);
        String str = sharedPreferences.getString(field, null);
        return str;
    }

    public static void setUserAppMessage(String field, String value) {
        Context context = StoreApplication.getContext();
        SharedPreferences sharedPreferences = context.getSharedPreferences("ChuangMeiARIndoorLocationMessage",
                Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putString(field, value);
        edit.commit();
    }

    public static String getUserAppMessage(String field) {
        Context context = StoreApplication.getContext();
        SharedPreferences sharedPreferences = context.getSharedPreferences("ChuangMeiARIndoorLocationMessage",
                Context.MODE_PRIVATE);
        String string = sharedPreferences.getString(field, null);
        return string;
    }

    public static void isUserFirstLogin(String field, boolean value) {
        Context context = StoreApplication.getContext();
        SharedPreferences sharedPreferences = context.getSharedPreferences("ChuangMeiARIndoorLocationMessage",
                Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putBoolean(field, value);
        edit.commit();
    }

    public static boolean getUserAppIsFirstLoginMessage(String field) {
        Context context = StoreApplication.getContext();
        SharedPreferences sharedPreferences = context.getSharedPreferences("ChuangMeiARIndoorLocationMessage",
                Context.MODE_PRIVATE);
        boolean aBoolean = sharedPreferences.getBoolean(field, true);
        return aBoolean;
    }


}
